How to sum an ndarray over ranges bounded by other indexes

welcome to shbcf.ru